<template>
  <div>
      <h1>第三题</h1>
      <!-- 任意方式, 求数组里每个学生的年龄和, 显示到页面上 -->
      <span>年龄和为：{{allYear}}</span>
  </div>
</template>

<script>
export default {
  data () {
    return {
      arr : [{
          name: "小明",
          age: 18
      }, {
          name: "小花",
          age: 25
      }, {
          name: "小爱",
          age: 21
      }],
    }
  },
  computed:{
    allYear () {
      return this.arr.reduce((a,b) => {
        a += b.age
        return a
      },0)
    }
  }

}
</script>

<style>

</style>